<?php 

namespace pmvc\mvc\security\basic;

use pmvc\mvc\security\AuthenticationProvider;

use pmvc\mvc\Request;
use pmvc\mvc\Response;

class BasicAuthenticationProvider
	implements AuthenticationProvider {

	private $usernameParamName 	= "_username";
	private $passwordParamName	= "_password";

	public function getAuthentication(Request $request, Response $response) {
		if ($request->hasParameter($this->usernameParamName)) {
			return new BasicAuthentication(
				$request->getParameter($this->usernameParamName),
				$request->getParameter($this->passwordParamName));
		} else {
			return NULL;
		}
	}

	public function setUsernameParamName($usernameParamName) {
		$this->usernameParamName = $usernameParamName;
	}

	public function setPasswordParamName($passwordParamName) {
		$this->passwordParamName = $passwordParamName;
	}

}

?>